import urllib.request

url = 'http://www.baidu.com'

response = urllib.request.urlopen(url)

# content = response.read().decode('utf-8')

# print(content)

# HTTPResponse
# print(type(response))

# 字节形式读取
# print(response.read(5))

# 读取一行
# print(response.readline())

# 读取每一行
content = response.readlines()
print(content)

print(response.getcode())

print(response.geturl())

print(response.getheaders())